#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
using namespace std; using ll = long long;
constexpr int N=1e6+5;
int n,m,deg[N],LIM,tot,head[N],tail[N],nxt[N],pre[N],val[N],qa[N],ha,ta,qb[N],hb,tb,done[N]; ll A,B,dis[N]; vector<int> to[N];
int main(){
	Fin("edge.in"); Fout("edge.out");
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>m>>A>>B; LIM=sqrt(m+0.5); For(i,1,m) { int x,y; cin>>x>>y; to[x].push_back(y); to[y].push_back(x); }
	For(i,1,n) deg[i]=to[i].size();
	For(u,1,n) if(deg[u]>LIM) {
		head[u]=++tot; tail[u]=++tot;
		nxt[head[u]]=tail[u]; pre[tail[u]]=head[u];
		for(int v:to[u]){
			val[tail[u]]=v; nxt[tail[u]]=++tot; pre[tot]=tail[u]; tail[u]=tot;
		}
	}
	For(i,1,n) dis[i]=1e18;
	qa[ta++]=1; dis[1]=0;
	while(ha<ta||hb<tb){
		int u; if(ha<ta&&(hb==tb||dis[qa[ha]]<dis[qb[hb]])) u=qa[ha++]; else u=qb[hb++];
		if(done[u]) continue; else done[u]=1;
		for(int v:to[u]) if(dis[v]>dis[u]+A) dis[v]=dis[u]+A,qa[ta++]=v;
		static int vis[N],VIS; VIS++;
		for(int v:to[u]) vis[v]=VIS;
		for(int w:to[u]) if(deg[w]<=LIM){
			for(int v:to[w]) if(vis[v]!=VIS){
				if(dis[v]>dis[u]+B) dis[v]=dis[u]+B,qb[tb++]=v;
			}
		}
		for(int w:to[u]) if(deg[w]>LIM){
			int o=nxt[head[w]];
			while(o!=tail[w]){
				if(vis[val[o]]==VIS) { o=nxt[o]; continue; }
				int v=val[o]; if(dis[v]>dis[u]+B) dis[v]=dis[u]+B,qb[tb++]=v;
				nxt[pre[o]]=nxt[o]; pre[nxt[o]]=pre[o]; o=nxt[o];
			}
		}
	}
	For(i,2,n) cout<<dis[i]<<'\n';
	return 0;
}